<template>
	<view>
		<nav-bar title="提现方式"></nav-bar>
        <!-- 公共组件-每个页面必须引入 -->
        <public-module></public-module>
		<view class="cell_list" @click="onPageJump(1102)">
			<view class="cell_left">
				<image src="../../../static/icon/wechat.png" mode="aspectFit"></image>
				<text>微信</text>
			</view>
			<view class="cell_right arrow" v-if="dealWayInfo.wxOpenId">已绑定</view>
			<view class="cell_right arrow" v-else>未绑定</view>
		</view>
		<view class="cell_list" @click="onPageJump(1101)">
			<view class="cell_left">
				<image src="../../../static/icon/zhifubao.png" mode="aspectFit"></image>
				<text>支付宝</text>
			</view>
			<view class="cell_right arrow" v-if="dealWayInfo.aliAccount">
				<text>{{dealWayInfo.aliRealName}}</text>
				<text>{{dealWayInfo.aliAccount}}</text>
			</view>
			<view class="cell_right arrow" v-else>未绑定</view>
		</view>
		<view class="cell_list" @click="onPageJump(1103)">
			<view class="cell_left">
				<image src="../../../static/icon/card2.png" mode="aspectFit"></image>
				<text>银行卡</text>
			</view>
			<view class="cell_right arrow" v-if="dealWayInfo.bankCardNum">
				<text>{{dealWayInfo.bankCardName}}</text>
				<text>{{dealWayInfo.bankCardNum}}</text>
			</view>
			<view class="cell_right arrow" v-else>未绑定</view>
		</view>
	</view>
</template>

<script>
import { mapState, mapMutations } from 'vuex';
export default {
	data() {
		return {
			dealWayInfo:{},
			type:""
		};
	},
	//第一次加载
	onLoad(e) {
		if(e.type){
			this.type = e.type;
		}
	},
	//页面显示
	onShow() {
		this.pageData();
	},
	//方法
	methods: {
		...mapMutations(["setPaymentMethod"]),
		onPageJump(type) {
			if(type == 1102){
				// 微信
				if(this.type == 'select'){
					if(this.dealWayInfo.wxOpenId){
						this.setPaymentMethod(type);
						uni.navigateBack();
					}else{
						uni.showModal({
							title:"提示",
							content:"您还未绑定微信，是否去绑定？",
							confirmText: "是",
							cancelText: "否",
							success: (res) => {
								if(res.confirm){
									uni.navigateTo({
										url: '/pagesMy/my/wallet/weChatBind'
									});
								}
							}
						})
					}
				}else{
					uni.navigateTo({
						url: '/pagesMy/my/wallet/weChatBind'
					});
				}
			}else if(type == 1101){
				// 支付宝
				if(this.type == 'select'){
					if(this.dealWayInfo.aliRealName && this.dealWayInfo.aliAccount){
						this.setPaymentMethod(type);
						uni.navigateBack();
					}else{
						uni.showModal({
							title:"提示",
							content:"您还未绑定支付宝，是否去绑定？",
							confirmText: "是",
							cancelText: "否",
							success: (res) => {
								if(res.confirm){
									uni.navigateTo({
										url: '/pagesMy/my/wallet/alipayBind'
									});
								}
							}
						})
					}
				}else{
					uni.navigateTo({
						url: '/pagesMy/my/wallet/alipayBind'
					});
				}
			}else if(type == 1103){
				// 银行卡
				if(this.type == 'select'){
					if(this.dealWayInfo.bankCardNum && this.dealWayInfo.bankCardName){
						this.setPaymentMethod(type);
						uni.navigateBack();
					}else{
						uni.showModal({
							title:"提示",
							content:"您还未绑定银行卡，是否去绑定？",
							confirmText: "是",
							cancelText: "否",
							success: (res) => {
								if(res.confirm){
									uni.navigateTo({
										url: '/pagesMy/my/wallet/cardBind'
									});
								}
							}
						})
					}
				}else{
					uni.navigateTo({
						url: '/pagesMy/my/wallet/cardBind'
					});
				}
			}
		},
		pageData() {
			this.$http
				.get('api/mime/wallet/v1/deal_way')
				.then(res => {
					this.dealWayInfo = res;
				});
		},
	},
	//页面隐藏
	onHide() {},
	//页面卸载
	onUnload() {},
	//页面下来刷新
	onPullDownRefresh() {},
	//页面上拉触底
	onReachBottom() {},
	//用户点击分享
	onShareAppMessage(e) {
		return this.wxShare();
	}
};
</script>
<style lang="scss" scoped>
@import '@/style/mixin.scss';
page {
	background-color: #f5f5f5;
}
.cell_list {
	box-shadow: 0rpx 8rpx 20rpx 0rpx rgba(44, 44, 44, 0.1);
	border-radius: 8rpx;
	margin: 20rpx 30rpx;
	padding: 40rpx 30rpx;
}
.cell_list .cell_left image {
	width: 48rpx;
	height: 48rpx;
}
.cell_list .cell_right text {
	margin-left: 20rpx;
}
</style>
